﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CHttp : MonoBehaviour
{
    public void StartCoroutineHttp(string url, UnityEngine.Events.UnityAction<WWW, string> action)
    {
        StartCoroutine(StartHttp(url, action));
    }

    private IEnumerator StartHttp(string url, UnityEngine.Events.UnityAction<WWW, string> action)
    {
        WWW www = new WWW(url);
        yield return www;
        if (!string.IsNullOrEmpty(www.error))
            Debug.LogError(www.error);
        else if (!www.isDone)
            Debug.LogError("www.isDone<<<" + www.isDone);
        else
        {
            action(www, url);
        }
    }
}
